﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp7
{
    public partial class Form4 : Form
    {
        private int id;

        public Form4()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            var SalaryString = textBox2.Text.ToString();

            var ManagerIdString = textBox3.Text.ToString();

            var Age = textBox1.Text;

            var Score= textBox2.Text;

            if (id > 0)
            {
                string conSting = string.Format("update Students set Name = '{0}',Age = '{1}' Score Id = {2}", id, Age, Score );

                var sql = DbHelper.AddOrEditSave(conSting);

                if (sql == 1)
                {
                    MessageBox.Show("成功!", "提示");

                    this.DialogResult = DialogResult.Yes;

                    this.Close();
                }
            }
            else
            {
                string cmdSting = string.Format("insert into Students(Age, Score)values('{0}', '{1}')", Age,Score);

                var ber = DbHelper.AddOrEditSave(cmdSting);

                if (ber == 1)
                {
                    MessageBox.Show("添加成功", "提示");

                    this.DialogResult = DialogResult.Yes;

                    this.Close();
                }
            }
        }
        //返回
        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
